﻿@{
    //page title
    ViewBag.Title = T("Admin.Configuration.Languages").Text;
}


<div class="row">
    <div class="col-md-12">
        <div class="x_panel light form-fit">
            <div class="x_title">
                <div class="caption">
                    <i class="fa fa-language"></i>
                    @T("Admin.Configuration.Languages")
                </div>
                <div class="actions btn-group btn-group-devided">
                    <a href="@Url.Action("Create")" class="btn green"><i class="fa fa-plus"></i><span class="d-none d-sm-inline"> @T("Admin.Common.AddNew") </span></a>
                    <vc:admin-widget widget-zone="language_list_buttons" additional-data="null" />
                </div>
            </div>
            <div class="x_content form">
                <div class="form-horizontal">
                    <div class="form-body">
                        <div class="x_content">
                            <div id="languages-grid"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script>
    $(document).ready(function () {
        $("#languages-grid").kendoGrid({
            dataSource: {
                transport: {
                    read: {
                        url: "@Html.Raw(Url.Action("List", "Language"))",
                        type: "POST",
                        dataType: "json",
                        data: addAntiForgeryToken
                    }
                },
                schema: {
                    data: "Data",
                    total: "Total",
                    errors: "Errors"
                },
                error: function(e) {
                    display_kendoui_grid_error(e);
                    // Cancel the changes
                    this.cancelChanges();
                },
                serverPaging: true,
                serverFiltering: true,
                serverSorting: true
            },
            pageable: {
                refresh: true,
                numeric: false,
                previousNext: false,
                info: false
            },
            editable: {
                confirmation: false,
                mode: "inline"
            },
            scrollable: false,
            columns: [{
                field: "Name",
                title: "@T("Admin.Configuration.Languages.Fields.Name")",
                template: '<a class="k-link" href="Edit/#=Id#">#=kendo.htmlEncode(Name)#</a>',
            },{
                field: "FlagImageFileName",
                title: "@T("Admin.Configuration.Languages.Fields.FlagImage")",
                width: 22,
                attributes: { style: "text-align:center" },
                template: '<img src="@Url.Content("~/content/images/flags/")#=FlagImageFileName#" />'
            },
            {
                field: "LanguageCulture",
                title: "@T("Admin.Configuration.Languages.Fields.LanguageCulture")",
                width: 200
            },{
                field: "DisplayOrder",
                title: "@T("Admin.Configuration.Languages.Fields.DisplayOrder")",
                width: 100
            }, {
                field: "Published",
                title: "@T("Admin.Configuration.Languages.Fields.Published")",
                width: 100,
                headerAttributes: { style: "text-align:center" },
                attributes: { style: "text-align:center" },
                template: '# if(Published) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'
            }]
        });
    });
</script>
        